package com.demo.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 徐老板
 * @date 2020/2/22   20:37
 */
@Configuration
@EnableSwagger2//一定要加这个注解 否则会进不去出不来那个swagger界面
public class SwaggerConfig {

    private String name;
    private String url;
    private String email;

    @Bean
    public Docket docket(ApiInfo apiInfo){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select().apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public ApiInfo apiInfo(){
       return new ApiInfoBuilder()
                .title("这个是稳定标题")
                .contact(new Contact(name, url, email))//联系方式
                .license("版本号")//这个是许可 没啥用
                .licenseUrl("版本号地址")
                .build();
    }

}
